﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DataSet : MonoBehaviour
{
    public Toggle[] toggles;
    public Button okBtn;
    public Button returnBtn;
    public int key;
    private int tempKey;
    public Text tipTxt;

    private void Start()
    {
        for (int i = 0; i < toggles.Length; i++)
        {
            int temp=i;
            toggles[i].onValueChanged.AddListener((bool b) => {
                if (toggles[temp].isOn)
                {
                    tempKey = temp;
                }
            });

        }

        okBtn.onClick.AddListener(CheckKey);


    }


    private void CheckKey()
    {

        if (tempKey == key)
        {
            Debug.Log("正确");
            tipTxt.text = "选项正确,请点击返回";
            tipTxt.gameObject.SetActive(true);
            returnBtn.interactable = true;
        }
        else
        {
            tipTxt.text = "选项有误，请重新选择";
            tipTxt.gameObject.SetActive(true);
        }


    }

}
